home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume4 / se / part1 next >
Encoding:
Internet Message Format  |  1986-11-30  |  26.4 KB

  1. From: Jeff Lee <talcott!seismo!gatech!jeff>
  2. Subject: Georgia Tech 'se' screen editor (Part 1 of 8)
  3. Keywords: Software Tools, Yet Another Screen Editor, Both BSD and USG
  4. Newsgroups: mod.sources
  5. Approved: jpn@panda.UUCP
  6.  
  7. Mod.sources:  Volume 4, Issue 82
  8. Submitted by: Jeff Lee <seismo!gatech!jeff>
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create:
  15. #    README
  16. #    ascii.h
  17. #    constdefs.h
  18. #    debug.h
  19. #    extern.h
  20. #    se.h
  21. #    m4munge
  22. #    where
  23. #    makefile
  24. # This archive created: Tue Apr 29 10:45:25 1986
  25. export PATH; PATH=/bin:/usr/bin:$PATH
  26. echo shar: "extracting 'README'" '(5755 characters)'
  27. if test -f 'README'
  28. then
  29.     echo shar: "will not over-write existing file 'README'"
  30. else
  31. cat << \SHAR_EOF > 'README'
  32. README:
  33.  
  34. This directory contains the source files for the Vax version of the Georgia
  35. Tech Screen Editor "Se".  It has three subdirectories which contain things
  36. that se needs. Here is a rundown of the various files.
  37.  
  38. Files containing documentation are:
  39.  
  40. README        -- this file.
  41. se.m4        -- nroff manual page for se (has to be munged to create se.1).
  42. scriptse.1    -- nroff manual page for scriptse.
  43.  
  44. The header files are:
  45.  
  46. ascii.h        -- definition of ASCII mnemonics and control characters.
  47. extern.h    -- external data definitions for the screen editor.
  48. se.h        -- global #define's for the screen editor.
  49. constdefs.h    -- global constants, also used by files in subdirectories.
  50.  
  51. The C source files are:
  52.  
  53. main.c        -- main program and declaration of globals, initialization.
  54. edit.c        -- main command loop to get and execute commands, file handling.
  55. docmd1.c    -- command decoder and functions for most commands.
  56. docmd2.c    -- functions for the rest of the commands.
  57. misc.c        -- miscellanious functions.
  58. scratch.c    -- scratch file manipulating functions.
  59. screen.c    -- routines to keep track of the screen contents.
  60. term.c        -- routines for changing the terminal.
  61.  
  62. The subdirectories are:
  63.  
  64. libchangetty    -- routines to change the terminal driver back and forth.
  65. pat        -- pattern matching routines.
  66. se_h        -- contains help scripts for all commands in se.
  67.  
  68. Miscellanious files:
  69.  
  70. where        -- shell file to determine System V (R 1 or 2), 4.1, or 4.2 BSD.
  71. m4munge        -- manipulate output of where for m4 for se man page
  72. makefile    -- the makefile for make(1).
  73. print2        -- inode used by make for printing only changed stuff.
  74.  
  75. scriptse.c    -- quick and dirty C program to make scripts for se.
  76. scriptse.1    -- manual page for same.
  77.  
  78. Executable files:
  79.  
  80. se        -- executable version of the screen editor.
  81. scriptse    -- the executable version of the script maker.
  82.  
  83.  
  84. Conditional Compilation flags:
  85.  
  86.     The flag HARD_TERMS, if added to the CFLAGS macro in the makefile,
  87. will remove the terminal-independant code which uses termlib, and put back
  88. the original, terminal-types-hardwired-into-the-program code.  The only
  89. reason to do this is if se has to run on a system without the termlib pacakage.
  90. Using termlib, se is considerably smaller, as well as more flexible.
  91.  
  92.     The flag OLD_SCRATCH, if added to the CFLAGS macro in the makefile,
  93. will cause se to use the original, linked-list method for keeping track of
  94. lines in the buffer.  This method is faster for rearranging lines, but
  95. considerably slower for simply looking up lines.  Currently, se uses the
  96. method given is Software Tools in Pascal, which keeps the lines in order in
  97. an array.  It is slower at rearranging, but as fast as possible for finding
  98. lines in the buffer.  This version also takes less data and code space.
  99.  
  100.     The flag OLD_GLOB, if added to the CFLAGS macro in the makefile,
  101. will keep se from special casing commands whose effect is to reverse the
  102. order of the lines in the buffer.  The special casing code can save an
  103. *incredible* amount of time for this pathological case, so it is best to leave
  104. things alone.  This only applies to the Software Tools in Pascal style
  105. line handling.
  106.  
  107.     The flag LOG_USAGE, if added to the CFLAGS macro in the makefile,
  108. will cause se to write usage "statistics" to a log file, consisting of the
  109. login name and time and date when an individual used se.  This is only done
  110. at Georgia Tech, and the logfile path name in the log() routine in edit.c
  111. should be changed to use a system accounting file somewhere.  It currently
  112. creates a file in /usr/tmp.
  113.  
  114.     The 'where' command creates a file called 'flags', which the makefile
  115. cats inside ``s.  These define and/or undefine the flags USG for System V,
  116. S5R2 if for Release 2, BSD for 4.1 and 4.2, and BSD4_2 for 4.2 specific code.
  117.  
  118. Miscellanious:
  119.  
  120.     Code which is dependant on the Berkeley job control stuff is also
  121. conditionally compiled in, so that on systems without it, it won't get in
  122. the way.
  123.  
  124.     Code has been added which should allow se to come up under USG Unix
  125. 5.0 (System V).  If S5R2 is defined, se will use the terminfo package.
  126. Otherwise, it assumes Release 1, and that the BSD termlib package has
  127. been ported and is available.
  128.  
  129.     The where program will also define or undefine GITVAX.  This is
  130. is used 1) to allow control-s and control-q as control characters, and
  131. 2) to come up in SWT mode.
  132.  
  133. Comments:
  134.  
  135.     It is a big piece of software. But, if you 1) read both Software Tools
  136. and Software Tools in Pascal (the chapters on editing and pattern matching, if
  137. you don't want to read all of the books), and 2) take your time, you should be
  138. able to understand, and eventually make changes to it, as necessary.
  139.  
  140. Authors:
  141.  
  142.     Se started out as the version of 'ed' that came with the book 'Sofware
  143. Tools', by Kernighan and Plauger, which was written in Ratfor. On the Pr1me
  144. computers at the School of Information and Computer Science at Georgia Tech,
  145. Dan Forsyth, Perry Flinn, and Alan Akin added all the enhancements suggested
  146. in the exercises in the book, and some more of their own. Jack Waugh made
  147. extensive modifications to turn it into a screen editor; further work was done
  148. by Dan Forsyth. All of this was in an improved Georgia Tech version of Ratfor.
  149.  
  150.     Later, Dan Forsyth, then (and now) at Medical Systems Develepment
  151. Corporation, converted the Ratfor version into C, for Berkeley Unix (4.1 BSD).
  152. At Georgia Tech, Arnold Robbins took the C version and added many new features
  153. and improvements, the most important of which was termcap support and System V
  154. support. The existing help screens were edited and completed at that time, as
  155. well. This was completed in early 1985.
  156.  
  157.     Arnold Robbins is now at ...!gatech!emory!arnold, and will make every
  158. reasonable attempt to answer any questions anyone may have about it, but in
  159. no way promises to support or enhance 'se'.
  160. SHAR_EOF
  161. fi
  162. echo shar: "extracting 'ascii.h'" '(1225 characters)'
  163. if test -f 'ascii.h'
  164. then
  165.     echo shar: "will not over-write existing file 'ascii.h'"
  166. else
  167. cat << \SHAR_EOF > 'ascii.h'
  168. /*
  169. ** ascii.h
  170. **
  171. ** definitions of ASCII mnemonics and synonyms.
  172. */
  173.  
  174. #ifndef    _ASCII_H
  175. #define    _ASCII_H
  176. #define    NUL    '\0'
  177. #define    SOH    '\001'
  178. #define    STX    '\002'
  179. #define    ETX    '\003'
  180. #define    EOT    '\004'
  181. #define    ENQ    '\005'
  182. #define    ACK    '\006'
  183. #define    BEL    '\007'
  184. #define    BS    '\010'
  185. #define    HT    '\011'
  186. #define    LF    '\012'
  187. #define    VT    '\013'
  188. #define    FF    '\014'
  189. #define    CR    '\015'
  190. #define    SO    '\016'
  191. #define    SI    '\017'
  192. #define    DLE    '\020'
  193. #define    DC1    '\021'
  194. #define    DC2    '\022'
  195. #define    DC3    '\023'
  196. #define    DC4    '\024'
  197. #define    NAK    '\025'
  198. #define    SYN    '\026'
  199. #define    ETB    '\027'
  200. #define    CAN    '\030'
  201. #define    EM    '\031'
  202. #define    SUB    '\032'
  203. #define    ESC    '\033'
  204. #define    FS    '\034'
  205. #define    GS    '\035'
  206. #define    RS    '\036'
  207. #define    US    '\037'
  208. #define    SP    '\040'
  209. #define    DEL    '\177'
  210. #define    CTRL_A    SOH
  211. #define    CTRL_B    STX
  212. #define    CTRL_C    ETX
  213. #define    CTRL_D    EOT
  214. #define    CTRL_E    ENQ
  215. #define    CTRL_F    ACK
  216. #define    CTRL_G    BEL
  217. #define    CTRL_H    BS
  218. #define    CTRL_I    HT
  219. #define    CTRL_J    LF
  220. #define    CTRL_K    VT
  221. #define    CTRL_L    FF
  222. #define    CTRL_M    CR
  223. #define    CTRL_N    SO
  224. #define    CTRL_O    SI
  225. #define    CTRL_P    DLE
  226. #define    CTRL_Q    DC1
  227. #define    CTRL_R    DC2
  228. #define    CTRL_S    DC3
  229. #define    CTRL_T    DC4
  230. #define    CTRL_U    NAK
  231. #define    CTRL_V    SYN
  232. #define    CTRL_W    ETB
  233. #define    CTRL_X    CAN
  234. #define    CTRL_Y    EM
  235. #define    CTRL_Z    SUB
  236. #endif
  237. SHAR_EOF
  238. fi
  239. echo shar: "extracting 'constdefs.h'" '(153 characters)'
  240. if test -f 'constdefs.h'
  241. then
  242.     echo shar: "will not over-write existing file 'constdefs.h'"
  243. else
  244. cat << \SHAR_EOF > 'constdefs.h'
  245. /*
  246. ** constdefs.h
  247. **
  248. ** Standard macro definitions for se screen editor
  249. */
  250.  
  251. #define    EOS '\0'
  252. #define    ERR (-3)
  253. #define    OK (-2)
  254. #define    NO 0
  255. #define    YES 1
  256. SHAR_EOF
  257. fi
  258. echo shar: "extracting 'debug.h'" '(119 characters)'
  259. if test -f 'debug.h'
  260. then
  261.     echo shar: "will not over-write existing file 'debug.h'"
  262. else
  263. cat << \SHAR_EOF > 'debug.h'
  264. /*
  265. ** debug.h
  266. **
  267. ** put debugging code into programs
  268. */
  269.  
  270. #ifdef DEBUG
  271. #define debug(x)    x
  272. #else
  273. #define debug(x)
  274. #endif
  275. SHAR_EOF
  276. fi
  277. echo shar: "extracting 'extern.h'" '(4918 characters)'
  278. if test -f 'extern.h'
  279. then
  280.     echo shar: "will not over-write existing file 'extern.h'"
  281. else
  282. cat << \SHAR_EOF > 'extern.h'
  283. /*
  284. ** extern.h
  285. **
  286. ** external data definitions
  287. ** for the screen editor
  288. */
  289.  
  290. /* Concerning line numbers: */
  291. extern int Line1;        /* first line number on command */
  292. extern int Line2;        /* second line number on command */
  293. extern int Nlines;        /* number of line numbers specified */
  294. extern int Curln;        /* current line; value of dot */
  295. extern int Lastln;        /* last line; value of dollar */
  296.  
  297.  
  298. /* Concerning patterns: */
  299. extern char Pat[MAXPAT];    /* saved pattern */
  300.  
  301.  
  302. /* Concerning the text of lines: */
  303. extern char Txt[MAXLINE];    /* text of current line */
  304.  
  305.  
  306. /* Concerning file names: */
  307. extern char Savfil[MAXLINE];    /* remembered file name */
  308.  
  309.  
  310. /* Concerning line descriptors: */
  311. extern LINEDESC Buf[MAXBUF];
  312. #ifdef OLD_SCRATCH
  313. extern LINEDESC *Lastbf;    /* last pointer used in Buf */
  314. extern LINEDESC *Free;        /* head of free list */
  315. #endif
  316. extern LINEDESC *Line0;        /* head of list of line descriptors */
  317.  
  318.  
  319. /* Concerning the 'undo' command: */
  320. extern LINEDESC *Limbo;        /* head of limbo list for undo */
  321. extern int Limcnt;        /* number of lines in limbo list */
  322.  
  323.  
  324. /* Concerning the scratch file: */
  325. extern filedes Scr;        /* scratch file descriptor */
  326. extern unsigned Scrend;        /* end of info on scratch file */
  327. extern char Scrname[MAXLINE];    /* name of scratch file */
  328. extern int Lost_lines;        /* number of garbage lines in scratch file */
  329.  
  330.  
  331. /* Concerning miscellaneous variables */
  332. extern int Buffer_changed;    /* YES if buffer changed since last write */
  333. extern int Errcode;        /* cause of most recent error */
  334. extern int Saverrcode;        /* cause of previous error */
  335. extern int Probation;        /* YES if unsaved buffer can be destroyed */
  336. extern int Argno;        /* command line argument pointer */
  337. extern char Last_char_scanned;    /* last char scanned with ctl-s or -l */
  338. #ifdef HARD_TERMS
  339. extern int Tspeed;        /* terminal speed in characters/second */
  340. #endif
  341. extern char Peekc;        /* push a SKIP_RIGHT if adding delimiters */
  342. #ifdef BSD4_2
  343. extern int Reading;        /* are we doing terminal input? */
  344. #endif
  345.  
  346.  
  347. /* Concerning options: */
  348. extern int Tabstops[MAXLINE];    /* array of tab stops */
  349. extern char Unprintable;    /* char to print for unprintable chars */
  350. extern int Absnos;        /* use absolute numbers in margin */
  351. extern int Nchoise;        /* choice of line number for cont. display */
  352. extern int Overlay_col;        /* initial cursor column for 'v' command */
  353. extern int Warncol;        /* where to turn on column warning */
  354. extern int Firstcol;        /* leftmost column to display */
  355. extern int Indent;        /* indent col; 0=same as previous line */
  356. extern int Notify;        /* notify user if he has mail in mail file */
  357. extern int Globals;        /* substitutes in a global don't fail */
  358. extern int No_hardware;        /* never use hardware insert/delete */
  359.  
  360.  
  361. #ifdef HARD_TERMS
  362. /* Concerning the terminal type */
  363. extern int Term_type;          /* terminal type */
  364. #endif
  365.  
  366.  
  367. /* Concerning the screen format: */
  368. extern char Screen_image[MAXROWS][MAXCOLS];
  369. extern char Msgalloc[MAXCOLS];    /* column allocation of status line */
  370. extern int Nrows;        /* number of rows on screen */
  371. extern int Ncols;        /* number of columns on screen */
  372. extern int Currow;        /* vertical cursor coordinate */
  373. extern int Curcol;        /* horizontal cursor coordinate */
  374. extern int Toprow;        /* top row of window field on screen */
  375. extern int Botrow;        /* bottom row of window field on screen */
  376. extern int Cmdrow;        /* row number of command line */
  377. extern int Topln;        /* line number of first line on screen */
  378. extern int Insert_mode;        /* flag to specify character insertion */
  379. extern int Invert_case;        /* flag to specify case mapping on input */
  380. extern int First_affected;    /* number of first line affected by cmd */
  381. extern int Rel_a;        /* char to use for first alpha line number */
  382. extern int Rel_z;        /* char to use for last alpha line number */
  383. extern int Scline[MAXROWS];    /* lines currently on screen (rel to Sctop) */
  384. extern int Sctop;        /* first line currently on screen */
  385. extern int Sclen;        /* number of lines currently on screen */
  386. extern char Blanks[MAXCOLS];    /* all blanks for filling in lines on screen */
  387. extern char Tobuf[MAXTOBUF];    /* buffer for collecting terminal output */
  388. extern char *Tobp;        /* pointer to last used part of Tobuf */
  389.  
  390.  
  391. /* Concerning interrupts: */
  392. extern int Int_caught;        /* caught a SIGINT from user */
  393. extern int Hup_caught;        /* caught a SIGHUP when phone line dropped */
  394. #ifdef SIGTSTP
  395. extern int Catching_stops;    /* catching or ignoring SIGTSTP's? */
  396. #endif
  397.  
  398. /* Concerning Unix and SWT compatiblity: */
  399. extern int Unix_mode;        /* behaving like Unix editors? */
  400. extern char BACKSCAN;        /* back scan character */
  401. extern char NOTINCCL;        /* class negation character */
  402. extern char XMARK;        /* global exclude on mark name */
  403. extern char ESCAPE;        /* escape character */
  404.  
  405. /* Concerning Georgia Tech I.C.S. specific code: */
  406. extern int At_gtics;        /* are we at Georgia Tech ICS? */
  407.  
  408. /* Concerning file encryption: */
  409. extern int Crypting;        /* doing file encryption? */
  410. extern char Key[KEYSIZE];    /* encryption key */
  411. SHAR_EOF
  412. fi
  413. echo shar: "extracting 'se.h'" '(7529 characters)'
  414. if test -f 'se.h'
  415. then
  416.     echo shar: "will not over-write existing file 'se.h'"
  417. else
  418. cat << \SHAR_EOF > 'se.h'
  419. /* se.h    --- definitions    for the    screen editor */
  420.  
  421. #include <stdio.h>
  422. #include <ctype.h>
  423. #include <signal.h>
  424.  
  425. /* some standard definitions used throughout the screen editor */
  426. #include "constdefs.h"
  427. #include "ascii.h"    /* definitions of ascii characters */
  428.  
  429. /* new data types */
  430. typedef    int filedes;        /* Unix    file descriptor    */
  431.  
  432. typedef    struct ldesc {        /* line    descriptor */
  433. #ifdef OLD_SCRATCH
  434.     struct    ldesc *Prevline; /* link to previous line */
  435.     struct    ldesc *Nextline; /* link to next line */
  436. #endif
  437.     unsigned Seekaddr;    /* scratch file seek address / 8 */
  438.     unsigned Lineleng : 16;    /* line length    including NL  EOS */
  439.     unsigned Globmark : 1;    /* mark for global commands */
  440.     unsigned Markname : 7;    /* mark name associated with line */
  441. } LINEDESC;
  442.  
  443. /* Language extensions */
  444. #define min(a,b)    ((a)<(b)?(a):(b))
  445. #define max(a,b)    ((a)>(b)?(a):(b))
  446. #define SKIPBL(l,i)    while (l[i] == ' ') (i)++
  447.  
  448. /* save a little procedure call overhead... */
  449. #define remark(text)    mesg(text, REMARK_MSG)
  450.  
  451. /* Arbitrary definitions */
  452. #define BACKWARD    -1
  453. #define FORWARD        0
  454. #define NOSTATUS    1
  455. #define NOMORE        0
  456. #define NEWLINE        '\n'
  457. #define TAB        '\t'
  458. #define RETERR    1
  459. #define RETOK    0
  460.  
  461. /* Array dimensions and    other limit values */
  462. #define MAXBUF        8192
  463. #define MAXTOBUF    512
  464. #define MAXCHARS    10
  465. #define MAXROWS        200
  466. #define MINROWS        16
  467. #define MAXCOLS        200
  468. #define MAXLINE        512
  469. #define MAXPAT        512
  470. #define GARB_FACTOR    2
  471. #define GARB_THRESHOLD    1000
  472. #define BUFENT        1
  473. #define KEYSIZE        11
  474.  
  475. /* Message classes for status line at bottom of    screen */
  476. #define NOMSG        0
  477. #define REMARK_MSG    1
  478. #define CHAR_MSG    2
  479. #define CASE_MSG    3
  480. #define INS_MSG        4
  481. #define TIME_MSG    5
  482. #define FILE_MSG    6
  483. #define COL_MSG        7
  484. #define LINE_MSG    8
  485. #define COMPRESS_MSG    9
  486. #define HELP_MSG    10
  487. #define MODE_MSG    11
  488. #define CRYPT_MSG    12
  489.  
  490. /* Characters typed by the user    */
  491. #define ANYWAY        '!'
  492. #define APPENDCOM    'a'
  493. #define UCAPPENDCOM    'A'
  494. #define BACKSEARCH    '<'
  495. #define CHANGE        'c'
  496. #define UCCHANGE    'C'
  497. #define COPYCOM        't'
  498. #define UCCOPYCOM    'T'
  499. #define CURLINE        '.'
  500. #define DEFAULTNAME    ' '
  501. #define DELCOM        'd'
  502. #define UCDELCOM    'D'
  503. #define ENTER        'e'
  504. #define UCENTER        'E'
  505. #define EXCLUDE        'x'
  506. #define UCEXCLUDE    'X'
  507. #define GLOBAL        'g'
  508. #define UCGLOBAL    'G'
  509. #define GMARK        '\''
  510. #define HELP        'h'
  511. #define UCHELP        'H'
  512. #define INSERT        'i'
  513. #define UCINSERT    'I'
  514. #define JOINCOM        'j'
  515. #define UCJOINCOM    'J'
  516. #define LASTLINE    '$'
  517. #define LOCATECMD    'l'
  518. #define UCLOCATECMD    'L'
  519. #define MARKCOM        'k'
  520. #define UCMARKCOM    'K'
  521. #define MOVECOM        'm'
  522. #define UCMOVECOM    'M'
  523. #define NAMECOM        'n'
  524. #define UCNAMECOM    'N'
  525. #define OPTCOM        'o'
  526. #define UCOPTCOM    'O'
  527. #define PAGECOM        ':'
  528. #define OVERLAYCOM    'v'
  529. #define UCOVERLAYCOM    'V'
  530. #define PREVLINE    '^'
  531. #define PREVLINE2    '-'
  532. #define PRINT        'p'
  533. #define UCPRINT        'P'
  534. #define PRINTCUR    '='
  535. #define PRINTFIL    'f'
  536. #define UCPRINTFIL    'F'
  537. #define QUIT        'q'
  538. #define UCQUIT        'Q'
  539. #define READCOM        'r'
  540. #define UCREADCOM    'R'
  541. #define SCAN        '/'
  542. #define SEARCH        '>'
  543. #define SUBSTITUTE    's'
  544. #define UCSUBSTITUTE    'S'
  545. #define TLITCOM        'y'
  546. #define UCTLITCOM    'Y'
  547. #define TOPLINE        '#'
  548. #define UNDOCOM        'u'
  549. #define UCUNDOCOM    'U'
  550. #define WRITECOM    'w'
  551. #define UCWRITECOM    'W'
  552. #define MISCCOM        'z'
  553. #define UCMISCCOM    'Z'
  554. #define SHELLCOM    '!'
  555.  
  556. /* Error message numbers.  Arbitrary so    long as    they are different. */
  557. #define EBACKWARD    1
  558. #define ENOPAT        2
  559. #define EBADPAT        3
  560. #define EBADSTR        4
  561. #define EBADSUB        5
  562. #define ECANTREAD    6
  563. #define EEGARB        7
  564. #define EFILEN        8
  565. #define EBADTABS    9
  566. #define EINSIDEOUT    10
  567. #define EKNOTFND    11
  568. #define ELINE1        12
  569. #define E2LONG        13
  570. #define ENOERR        14
  571. #define ENOLIMBO    15
  572. #define EODLSSGTR    16
  573. #define EORANGE        17
  574. #define EOWHAT        18
  575. #define EPNOTFND    19
  576. #define ESTUPID        20
  577. #define EWHATZAT    21
  578. #define EBREAK        22
  579. #define ELINE2        23
  580. #define ECANTWRITE    24
  581. #define ECANTINJECT    25
  582. #define ENOMATCH    26
  583. #define ENOFN        27
  584. #define EBADLIST    28
  585. #define ENOLIST        29
  586. #define ENONSENSE    30
  587. #define ENOHELP        31
  588. #define EBADLNR        32
  589. #define EFEXISTS    33
  590. #define EBADCOL        34
  591. #define ENOLANG        35
  592. #define ETRUNC        36
  593. #define ENOSHELL    37
  594. #define ECANTFORK    38
  595. #define EHANGUP        39
  596. #define ENOSUB        40
  597. #define ENOCMD        41
  598.  
  599. #ifdef HARD_TERMS
  600. /* Terminal types */
  601. #define NOTERM        0    /* type    not known yet */
  602. #define ADDS980        1    /* ADDS    Consul 980 */
  603. #define ADDS100        2    /* ADDS    Regent 100, 20,    40, etc    */
  604. #define FOX        3    /* Perkin-Elmer    1100 */
  605. #define TVT        4    /* Allen's SWTPC T. V. Typewriter II */
  606. #define GT40        5    /* DEC GT40 with Waugh terminal    program    */
  607. #define BEE150        6    /* Beehive 150 */
  608. #define BEE200        7    /* Beehive 200 */
  609. #define SBEE        8    /* Beehive Super-Bee */
  610. #define SOL        9    /* Sol emulating Beehive 200 */
  611. #define HAZ1510        10    /* Hazeltine 1500 series */
  612. #define CG        11    /* Chromatics CG */
  613. #define ISC8001        12    /* ISC 8001 color terminal */
  614. #define ADM3A        13    /* Lear-Siegler    ADM 3A */
  615. #define IBM        14    /* IBM 3101 */
  616. #define ANP        15    /* Allen & Paul    model 1    */
  617. #define NETRON        16    /* Netronics */
  618. #define H19        17    /* Heath H19/Zenith Z19    */
  619. #define TRS80        18    /* Radio Shaft TRS80 */
  620. #define HP21        19    /* Hewlett-Packard 2621A/P */
  621. #define ADM31        20    /* Lear-Siegler    ADM 31 */
  622. #define VI200        21    /* VIsual 200 terminal */
  623. #define VC4404        22    /* Volker-Craig    4404 */
  624. #define ESPRIT        23    /* Hazeltine Esprit (Hazeltine mode) */
  625. #define TS1        24    /* Falco TS-1 */
  626. #define TVI950        25    /* Televideo 950 */
  627. #define VI50        26    /* Visual 50 */
  628. #define VI300        27    /* Visual 300    */
  629. #endif
  630.  
  631. /* Screen design positions */
  632. #define NAMECOL        5    /* column to put mark name in */
  633. #define BARCOL        6    /* column for "|" divider */
  634. #define POOPCOL        7    /* column for text to start in */
  635.  
  636. /* Control characters */
  637.  
  638. /* Leftward cursor motion */
  639. #define CURSOR_LEFT        CTRL_H    /* left    one column */
  640. #define TAB_LEFT        CTRL_E    /* left    one tab    stop */
  641. #define SKIP_LEFT        CTRL_W    /* go to column    1 */
  642. #define SCAN_LEFT        CTRL_L    /* scan    left for a char    */
  643. #define G_LEFT            CTRL_U    /* erase char to left */
  644. #define G_TAB_LEFT        FS    /* erase to prev tab stop */
  645. #define KILL_LEFT        CTRL_Y    /* erase to column 1 */
  646. #define G_SCAN_LEFT        CTRL_N    /* scan    left and erase */
  647.  
  648. /* Rightward cursor motion */
  649. #define CURSOR_RIGHT        CTRL_G    /* right one column */
  650. #define TAB_RIGHT        CTRL_I    /* right one tab stop */
  651. #define SKIP_RIGHT        CTRL_O    /* go to end of    line */
  652. #ifdef GITVAX
  653. #define SCAN_RIGHT        CTRL_S    /* scan    right for char */
  654. #else
  655. #define SCAN_RIGHT        CTRL_J    /* scan    right for char */
  656. #endif
  657. #define G_RIGHT            CTRL_R    /* erase over cursor */
  658. #define G_TAB_RIGHT        RS    /* erase to next tab */
  659. #define KILL_RIGHT        CTRL_T    /* erase to end    of line    */
  660. #define G_SCAN_RIGHT        CTRL_B    /* scan    right and erase    */
  661.  
  662. /* Line    termination */
  663. #define T_SKIP_RIGHT        CTRL_V    /* skip    to end and terminate */
  664. #define T_KILL_RIGHT        CR    /* KILL_RIGHT,    SKIP_RIGHT_AND_TERM */
  665. #define FUNNY            CTRL_F    /* take    funny return */
  666. #define CURSOR_UP        CTRL_D    /* move    up one line */
  667. #define CURSOR_DOWN        CTRL_K    /* move    down one line */
  668. #define CURSOR_SAME        CTRL_J    /* leave cursor    on same    line */
  669.  
  670. /* Insertion */
  671. #define INSERT_BLANK        CTRL_C    /* insert one blank */
  672. #define INSERT_TAB        CTRL_X    /* insert blanks to next tab */
  673. #define INSERT_NEWLINE        US    /* insert a newline */
  674.  
  675. /* Miscellany */
  676. #define TOGGLE_INSERT_MODE    CTRL_A    /* toggle insert mode flag */
  677. #define SHIFT_CASE        CTRL_Z    /* toggle case mapping flag */
  678. #define KILL_ALL        DEL    /* erase entire    line */
  679. #ifdef GITVAX
  680. #define FIX_SCREEN        CTRL_Q    /* clear and restore screen */
  681. #else
  682. #define FIX_SCREEN        GS    /* clear and restore screen */
  683. #endif
  684.  
  685. /* Function for moving around the buffer, either style line handling: */
  686. #ifdef OLD_SCRATCH
  687. #define NEXTLINE(k)    ((k) -> Nextline)
  688. #else
  689. #define NEXTLINE(k)    (((k) < &Buf[Lastln]) ? (k) + 1 : Line0)
  690. #endif
  691. SHAR_EOF
  692. fi
  693. echo shar: "extracting 'm4munge'" '(548 characters)'
  694. if test -f 'm4munge'
  695. then
  696.     echo shar: "will not over-write existing file 'm4munge'"
  697. else
  698. cat << \SHAR_EOF > 'm4munge'
  699. #! /bin/sh
  700. # m4munge --- take what the 'where' command produces, and change it for m4
  701.  
  702. for i in $*
  703. do
  704.     case $i in
  705.     -DUSG)        echo 'define(USG,YES)'        ;;
  706.     -UUSG)        echo 'define(USG,NO)'        ;;
  707.     -DBSD)        echo 'define(BSD,YES)'        ;;
  708.     -UBSD)        echo 'define(BSD,NO)'        ;;
  709.     -DBSD4_2)    echo 'define(BSD4_2,YES)'    ;;
  710.     -UBSD4_2)    echo 'define(BSD4_2,NO)'    ;;
  711.     -DGITVAX)    echo 'define(GITVAX,YES)'    ;;
  712.     -UGITVAX)    echo 'define(GITVAX,NO)'    ;;
  713.     -DS5R2)        echo 'define(S5R2,YES)'        ;;
  714.     -US5R2)        echo 'define(S5R2,NO)'        ;;
  715.     -DHARD_TERMS)    echo 'define(HARD_TERMS,YES)'    ;;
  716.     esac
  717. done
  718. SHAR_EOF
  719. chmod +x 'm4munge'
  720. fi
  721. echo shar: "extracting 'where'" '(1263 characters)'
  722. if test -f 'where'
  723. then
  724.     echo shar: "will not over-write existing file 'where'"
  725. else
  726. cat << \SHAR_EOF > 'where'
  727. #! /bin/sh
  728.  
  729. # where --- shell file to determine what kind of environment we are in
  730.  
  731. if test -r /bin/universe    # on a pyramid
  732. then
  733.     OPATH=$PATH
  734.     PATH=/bin
  735.     case `universe` in    # universe is dumb, looking only at argv[0]
  736.     att)    echo "-DUSG -UBSD -UBSD4_2"
  737.         if grep LOBLK /usr/include/sys/termio.h > /dev/null
  738.         then
  739.             echo -DS5R2
  740.         else
  741.             echo -US5R2
  742.         fi
  743.         ;;
  744.  
  745.     ucb)    echo "-UUSG -DBSD -DBSD4_2 -US5R2"
  746.         ;;
  747.  
  748.     *)    echo unknown operating system! 1>&2
  749.         echo "-UUSG -UBSD -UBSD4_2"    # undefine them all
  750.         echo "-US5R2"
  751.         ;;
  752.     esac
  753.     PATH=$OPATH
  754.     echo -UGITVAX    # pyramid is never GITVAX
  755. else        # on something that is not a pyrmaid
  756.     if grep SIGTSTP /usr/include/signal.h > /dev/null
  757.     then        # berkeley unix
  758.         if test -r /usr/include/whoami.h    # 4.1
  759.         then
  760.             echo "-UUSG -DBSD -UBSD4_2"
  761.             host="`sed 's/[^\"]*\"\([^\"]*\)\"/\1/' < /usr/include/whoami.h`"
  762.         else                    # 4.2
  763.             echo "-UUSG -DBSD -DBSD4_2"
  764.             host=`hostname`
  765.         fi
  766.         case $host in
  767.         gatech | \
  768.         gt-nimbus | nimbus | \
  769.         gt-cirrus | cirrus | \
  770.         gt-stratus | stratus)    echo -DGITVAX
  771.                 ;;
  772.         
  773.         *)    echo -UGITVAX
  774.             ;;
  775.         esac
  776.         echo -US5R2
  777.     else            # ATT unix
  778.         echo "-DUSG -UBSD -UBSD4_2"
  779.         if grep LOBLK /usr/include/sys/termio.h > /dev/null
  780.         then
  781.             echo -DS5R2
  782.         else
  783.             echo -US5R2
  784.         fi
  785.         echo -UGITVAX
  786.     fi
  787. fi
  788. SHAR_EOF
  789. chmod +x 'where'
  790. fi
  791. echo shar: "extracting 'makefile'" '(3113 characters)'
  792. if test -f 'makefile'
  793. then
  794.     echo shar: "will not over-write existing file 'makefile'"
  795. else
  796. cat << \SHAR_EOF > 'makefile'
  797. # makefile for the Georgia Tech Screen Editor, 'se'
  798.  
  799. HEADERS= ascii.h constdefs.h extern.h se.h
  800.  
  801. SRCS= docmd1.c docmd2.c edit.c main.c misc.c scratch.c screen.c term.c
  802. OBJS= docmd1.o docmd2.o edit.o main.o misc.o scratch.o screen.o term.o
  803.  
  804. LIBRARIES= libchangetty/libchangetty.a pat/libpat.a
  805.  
  806. LIBS=`echo $(LIBRARIES); if egrep 'DBSD|US5R2' flags > /dev/null; then echo -ltermlib; else echo -lcurses; fi`
  807.  
  808. DOCS= makefile README changes.made
  809. MANS= scriptse.1 se.1
  810.  
  811. CFLAGS= -O `cat flags`
  812. LDFLAGS=
  813.  
  814. # On BSD systems, force make to use the right shell for commands
  815. SHELL=/bin/sh
  816.  
  817. ###########################################################################
  818. # Begin system dependant macro definitions
  819.  
  820. # PR is to print the files nicely.  Use pr -n if available, or else just pr
  821. # I use a private utility called 'prt'
  822. PR=prt
  823.  
  824. # NROFF is for nroffing.  we use the System V nroff. 
  825. NROFF=/usr/5bin/nroff
  826.  
  827. # MANSEC is where to put the manual pages. Use 'l' for local, otherwise '1'.
  828. MANSEC=l
  829.  
  830. # DESTBIN is where se and scriptse will go
  831. DESTBIN= /usr/local/bin
  832.  
  833. # OWNER and GROUP are the owner and group respectively
  834. OWNER= root
  835. GROUP= admin
  836.  
  837. # INSTALL is the program to do the installation, use cp for real work
  838. INSTALL= cp
  839.  
  840. # CHOWN changes the owner.
  841. CHOWN= /etc/chown
  842.  
  843. # CHGRP changes the group.
  844. CHGRP= chgrp
  845.  
  846. # CHMOD will change permissions.
  847. CHMOD= chmod
  848.  
  849. ########
  850. # other things to change:
  851. #
  852. # on non-BSD systems, change the 'lpr' below to 'lp'
  853. ########
  854.  
  855. # Begin list of dependencies
  856.  
  857. all: se scriptse se.1
  858.     @echo all done
  859.  
  860. se: $(OBJS) $(LIBRARIES)
  861.     $(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
  862.  
  863. $(OBJS): $(HEADERS) flags
  864.  
  865. flags: where
  866.     where > flags
  867.  
  868. libchangetty/libchangetty.a: libchangetty/changetty.c
  869.     cd libchangetty; make
  870.  
  871. pat/libpat.a: pat/pat.c
  872.     cd pat; make
  873.  
  874. scriptse: scriptse.c
  875.     $(CC) -O scriptse.c -o scriptse
  876.  
  877. se.1: se.m4 flags
  878.     (m4munge $(CFLAGS) ; cat se.m4) | m4 | sed '/^$$/d' > se.1
  879.  
  880. install: all $(MANS)
  881.     $(INSTALL) se $(DESTBIN)
  882.     $(CHOWN) $(OWNER) $(DESTBIN)/se
  883.     $(CHGRP) $(GROUP) $(DESTBIN)/se
  884.     $(CHMOD) 711 $(DESTBIN)/se 
  885.     $(INSTALL) scriptse $(DESTBIN)
  886.     $(CHOWN) $(OWNER) $(DESTBIN)/scriptse
  887.     $(CHGRP) $(GROUP) $(DESTBIN)/scriptse
  888.     $(CHMOD) 711 $(DESTBIN)/scriptse 
  889.     $(INSTALL) se.1 /usr/man/man$(MANSEC)/se.$(MANSEC)
  890.     $(CHOWN) $(OWNER) /usr/man/man$(MANSEC)/se.$(MANSEC)
  891.     $(CHGRP) $(GROUP) /usr/man/man$(MANSEC)/se.$(MANSEC)
  892.     $(CHMOD) 644 /usr/man/man$(MANSEC)/se.$(MANSEC)
  893.     $(INSTALL) scriptse.1 /usr/man/man$(MANSEC)/scriptse.$(MANSEC)
  894.     $(CHOWN) $(OWNER) /usr/man/man$(MANSEC)/scriptse.$(MANSEC)
  895.     $(CHGRP) $(GROUP) /usr/man/man$(MANSEC)/scriptse.$(MANSEC)
  896.     $(CHMOD) 644 /usr/man/man$(MANSEC)/scriptse.$(MANSEC)
  897.     cd se_h; make install
  898.     
  899. print:
  900.     $(PR) $(HEADERS) $(SRCS) $(DOCS) $(MANS) | lpr
  901.  
  902. printman: $(MANS)
  903.     $(NROFF) -man $(MANS) | col | lpr
  904.  
  905. print2:    $(HEADERS) $(SRCS) $(DOCS) $(MANS)
  906.     $(PR) $? | lpr
  907.  
  908. printall: printman print
  909.     cd pat; make print
  910.     cd libchangetty; make print
  911.     cd se_h; make print
  912.  
  913. clean:
  914.     rm -f *.o print2
  915.     cd pat; make clean
  916.     cd libchangetty; make clean
  917.  
  918. clobber: clean
  919.     rm -f se scriptse flags se.1
  920.     cd pat; make clobber
  921.     cd libchangetty; make clobber
  922.     cd se_h; make clobber
  923. SHAR_EOF
  924. fi
  925. exit 0
  926. #    End of shell archive
  927.  
  928.